package com.tourism.home.controller.system;

import com.tourism.home.entity.Result;
import com.tourism.home.service.ScenicService;
import com.tourism.home.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ScenicController {
    @Autowired
    ScenicService scenicService;

    @GetMapping(value = "/scenic/type/{type}")
    Result getScenicByType(@PathVariable("type") String type){
        Object object = scenicService.getScenicByType(type);
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.error(null);
        }
    }

    @GetMapping(value = "/scenic/address/{address}")
    Result getScenicByAddress(@PathVariable("address") String address){
        Object object = scenicService.getScenicByAddress(address);
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.error(null);
        }
    }

    @GetMapping(value = "/scenic/title/{title}")
    Result getScenicByTitle(@PathVariable("title") String title){
        Object object = scenicService.getScenicByTitle(title);
        if(object != null){
            return ResultUtil.success(object);
        }else {
            return ResultUtil.error(null);
        }
    }

}
